﻿Imports System.Data.OleDb
Imports BUS
Imports DTO

Public Class frmQuyen
    Dim dataset As DataSet
    Dim quyenBindingSource As BindingSource
    Dim quyenNguoiDungBindingSource As BindingSource


    Private Sub frmQuyen_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        LoadData()
        BindingSource()
    End Sub

    Public Sub LoadData()
        dataset = New DataSet
        dataset.Tables.Add(NhanVienBus.LayNguoiDung())
        dataset.Tables.Add(NhanVienBus.LayQuyen())

        dataset.Tables(0).TableName = "NguoiDung"
        dataset.Tables(1).TableName = "Quyen"
        

        quyenBindingSource.DataSource = dataset
        quyenBindingSource.DataMember = "Quyen"
        
        dataset.Relations.Add("QuyenNguoiDung", dataset.Tables(0).Columns("Maquyen"), dataset.Tables(1).Columns("MaQuyen"))
        
        quyenNguoiDungBindingSource.DataSource = quyenBindingSource
        quyenNguoiDungBindingSource.DataMember = "QuyenNguoiDung"
    End Sub

    Public Sub BindingSource()
        dgvQuyen.DataSource = quyenBindingSource
        dgvNguoiDung.DataSource = quyenNguoiDungBindingSource
    End Sub
End Class